package com.zhuoshi.serviceImpl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.zhuoshi.entity.Openingreport;
import com.zhuoshi.entity.OpeningreportQueryVo;
import com.zhuoshi.entity.PayMentTypeCustom;
import com.zhuoshi.entity.RoomCustom;
import com.zhuoshi.mapper.OpeningreportMapper;
import com.zhuoshi.mapper.OpeningreporthouseparticularMapper;
import com.zhuoshi.service.OpeningreportService;

@Service("openingreportService")
@Transactional
public class OpeningreportServiceImpl implements OpeningreportService{
	
	@Autowired
	private OpeningreportMapper openingreportMapper;
	@Autowired
	private OpeningreporthouseparticularMapper openingreporthouseparticularMapper;
	
//		添加开盘基本信息
	public Integer addOpeningreport(Openingreport openingreport) throws Exception {
		int insert = openingreportMapper.insert(openingreport);
		return insert;
	}

	public Openingreport selectOpeningreportById(Integer id) throws Exception {
		// TODO Auto-generated method stub
		return openingreportMapper.selectByPrimaryKey(id);
	}

	public List<Openingreport> selectOpeningreportAll(List<RoomCustom> roomCustoms,List<PayMentTypeCustom> payMentTypeCustoms,Openingreport openingreport) throws Exception {
		OpeningreportQueryVo openingreportQueryVo=new OpeningreportQueryVo();
		openingreportQueryVo.setOpeningreport(openingreport);
		for (RoomCustom RoomCustom : roomCustoms) {
			openingreportQueryVo.setRoomCustom(RoomCustom);
			for (PayMentTypeCustom payMentTypeCustom : payMentTypeCustoms) {
				openingreportQueryVo.setPayMentTypeCustom(payMentTypeCustom);
//				#{openingreport.id}, #{roomCustom.id}, 
//			      #{payMentTypeCustom.id}, #{roomCustom.roomtotal}, #{roomCustom.roomprice}
				
				openingreporthouseparticularMapper.add(openingreportQueryVo);
			}
		}
		return openingreportMapper.selectByExample(null);
	}
//	模糊查询开盘
	public List<Openingreport> selectOpeningreportLike(String value) throws Exception {
		// TODO Auto-generated method stub
		return openingreportMapper.selectOpeningreportLike(value);
	}

}
